using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Facebook.Entity;

namespace DevicePhotoSample
{
    public partial class AlbumPropertiesForm : Form
    {
        private MainForm parent;
        private bool isnew = false;

        public AlbumPropertiesForm(MainForm parent, Album a)
        {
            this.parent = parent;

            InitializeComponent();

            if (a == null)
            {
                //this is a new album
                isnew = true;
            }
            else
            {
                txtName.Text = a.Name;
                txtName.ReadOnly = true;
                txtLocation.Text = a.Location;
                txtLocation.ReadOnly = true;
                txtDescription.Text = a.Description;
                txtDescription.ReadOnly = true;
            }
        }

        private void AlbumPropertiesForm_Closing(object sender, CancelEventArgs e)
        {
            if (isnew)
            {
                if(!string.IsNullOrEmpty(txtName.Text))
                {
                    Album newAlbum = parent.facebookService1.CreateAlbum(txtName.Text, txtLocation.Text, txtDescription.Text);
                    if (newAlbum != null)
                    {
                        MessageBox.Show("Your new Album has been created.", "New Album");
                    }
                }
            }
        }
    }
}